﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;

namespace OnlineBusTicket.Component
{
    public class BusListQuery
    {
        public IQueryable GetBusList()
        {
            //OnlineBusTicketEntities db = new OnlineBusTicketEntities();
            //var result = from a in db.BusLists
            //             join b in db.BusticKetDetails
            //             on a.BusListId equals b.BusListId
            //             select new { a.BusListId, a.DeparturePlace }
            //                ;
            //return result;
            OnlineBusTicketEntities db = new OnlineBusTicketEntities();
            var result = from a in db.BusLists
                         join b in db.TotalSeats
                         on a.BusListId equals b.BusListId
                         where a.DeparturePlace == Search.SDeparturePlace && a.ArrivePlace == Search.SArrivePlace && a.StartDate == Search.SDate && b.Seat<a.TotalNumberOfSeats
                         select new { a.BusListId, a.BusCategory, a.DeparturePlace, a.ArrivePlace, a.StartDate,a.EndDate , a.Time, a.Price};
            return result;
         //   using (var db = new OnlineBusTicketEntities())
         //   {
               
                //return db.BusLists.Where(x => x.DeparturePlace == SearchControl.DeparturePlace && x.ArrivePlace == SearchControl.ArrivePlace && x.StartDate==SearchControl.Date).ToList();
         //   }
        }
    }
}